package com.caijg.controller.user;

import com.caijg.domain.dto.EvaluationDTO;
import com.caijg.domain.vo.Result;
import com.caijg.service.IEvaluationResultService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;

/**
 * <p>
 * 评测结果表 前端控制器
 * </p>
 *
 * @author caijg
 * @since 2024-12-28
 */
@RestController
@RequestMapping("/user/evaluate")
@Tag(name = "体质评估模块")
@Slf4j
public class UserEvaluationResultController {

    @Autowired
    private IEvaluationResultService evaluationResultService;

    @Operation(summary = "体质评估")
    @PostMapping("/result")
    public Result getResult(@RequestBody EvaluationDTO evaluationDTO) throws Exception {
        log.info("用户作答完毕，开始体质评估...{}", evaluationDTO);
        return evaluationResultService.getResult(evaluationDTO);
    }

    @Operation(summary = "用户获取历史评测记录")
    @GetMapping("/history")
    public Result getHistory() {
        log.info("用户获取历史评测记录...");
        return evaluationResultService.getHistory();
    }

    @Operation(summary = "用户删除历史评测记录")
    @PostMapping("/delete")
    public Result deleteHistory(@RequestBody ArrayList<String> ids) {
        log.info("删除用户历史评测记录...{}", ids);
        return evaluationResultService.deleteHistory(ids);
    }
}
